<?php

/**
 * Override of theme_breadcrumb().
 */
function nic_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];
  if (!empty($breadcrumb)) {
    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
	$options = array ('attributes'=>array('id'=>'breadcrumbhome'));
	$breadcrumb[0] = l(t('Home'),'',$options);
    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
    $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
    return $output;
  }
}

/**
 * Override or insert variables into the maintenance page template.
 */
function nic_preprocess_maintenance_page(&$vars) {
  // While markup for normal pages is split into page.tpl.php and html.tpl.php,
  // the markup for the maintenance page is all in the single
  // maintenance-page.tpl.php template. So, to have what's done in
  // nic_preprocess_html() also happen on the maintenance page, it has to be
  // called here.
  nic_preprocess_html($vars);
}
function get_value($str) {
  $str = trim($str);
  return $str != '' ? $str : '--';
}
/**
 * Override or insert variables into the html template.
 */
function nic_preprocess_html(&$vars) {
  // Toggle fixed or fluid width.
  if (theme_get_setting('nic_width') == 'fluid') {
    $vars['classes_array'][] = 'fluid-width';
  }
  // Add conditional CSS for IE6.
  drupal_add_css(path_to_theme() . '/fix-ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css('http://cms.tn.gov.in/tncms_latest/sites/all/themes/nic/css/inner_page.css', array('type' => 'external'));
  drupal_add_js('http://cms.tn.gov.in/tncms_latest/sites/all/themes/nic/js/jquery.min.js', array('type' => 'external'));
  drupal_add_js('http://cms.tn.gov.in/tncms_latest/sites/all/themes/nic/js/popup.js', array('type' => 'external'));
  drupal_add_js('http://cms.tn.gov.in/tncms_latest/sites/all/themes/nic/js/selectajax.js', array('type' => 'external'));

}

/**
 * Override or insert variables into the html template.
 */
function nic_process_html(&$vars) {
  // Hook into color.module
  if (module_exists('color')) {
    _color_html_alter($vars);
  }
}

/**
 * Override or insert variables into the page template.
 */
function nic_preprocess_page(&$vars) {
  // Move secondary tabs into a separate variable.
  $vars['tabs2'] = array(
    '#theme' => 'menu_local_tasks',
    '#secondary' => $vars['tabs']['#secondary'],
  );
  unset($vars['tabs']['#secondary']);

  if (isset($vars['main_menu'])) {
    $vars['primary_nav'] = theme('links__system_main_menu', array(
      'links' => $vars['main_menu'],
      'attributes' => array(
        'class' => array('links', 'inline', 'main-menu'),
      ),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      )
    ));
  }
  else {
    $vars['primary_nav'] = FALSE;
  }
  if (isset($vars['secondary_menu'])) {
    $vars['secondary_nav'] = theme('links__system_secondary_menu', array(
      'links' => $vars['secondary_menu'],
      'attributes' => array(
        'class' => array('links', 'inline', 'secondary-menu'),
      ),
      'heading' => array(
        'text' => t('Secondary menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      )
    ));
  }
  else {
    $vars['secondary_nav'] = FALSE;
  }

  // Prepare header.
  $site_fields = array();
  if (!empty($vars['site_name'])) {
    $site_fields[] = $vars['site_name'];
  }
  if (!empty($vars['site_slogan'])) {
    $site_fields[] = $vars['site_slogan'];
  }
  $vars['site_title'] = implode(' ', $site_fields);
  if (!empty($site_fields)) {
    $site_fields[0] = '<span>' . $site_fields[0] . '</span>';
  }
  $vars['site_html'] = implode(' ', $site_fields);

  // Set a variable for the site name title and logo alt attributes text.
  $slogan_text = $vars['site_slogan'];
  $site_name_text = $vars['site_name'];
  $vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text;
}

/**
 * Override or insert variables into the node template.
 */
function nic_preprocess_node(&$vars) {
  $vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];
 if($vars['node'] && arg(2) != 'edit'){
       $vars['template_files'][] = 'templates/node--'. str_replace('_', '-', $vars['node']->type);
 }
 }

/**
 * Override or insert variables into the comment template.
 */
function nic_preprocess_comment(&$vars) {
  $vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
}

/**
 * Override or insert variables into the block template.
 */
function nic_preprocess_block(&$vars) {
  $vars['title_attributes_array']['class'][] = 'title';
  $vars['classes_array'][] = 'clearfix';
}

/**
 * Override or insert variables into the page template.
 */
function nic_process_page(&$vars) {
  // Hook into color.module
  if (module_exists('color')) {
    _color_page_alter($vars);
  }
}

/**
 * Override or insert variables into the region template.
 */
function nic_preprocess_region(&$vars) {
  if ($vars['region'] == 'header') {
    $vars['classes_array'][] = 'clearfix';
  }
}

function nic_theme(){
	return array(        
 		
		'documents_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-documents-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		'govt_orders_node_form' => array(
		'arguments' => array('form' => NULL),
        'template' => 'node-govt-orders-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
		),
		'addnewform_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-addnewform-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'notification_node_form'=> array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-notification-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'service_registration_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-service-registration-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
		 ),
		'press_releases_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-press-releases-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
		 ),
		 
		'rulesandregulation_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-rulesandregulation-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'announcements_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-announcements-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'profile_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-profile-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'organisation_details_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-organisation_details-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		'actform_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-actform-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'service_title_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-service-title-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'contact_dir_form_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-contactdirectory-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),	
		 'scheme_title_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-scheme-title-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'scheme_node_form' => array(     
          'arguments' => array('form' => NULL), 
          'template' => 'node-schemes-edit', 
          'path' => drupal_get_path('theme','nic').'/templates', 
          'render element' => 'form', 
         ),
		'website_entry_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-website-entry-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'eform_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-eform-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'eform_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-eform-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
         ),
		 'tender_node_form' => array(    
        'arguments' => array('form' => NULL),
        'template' => 'node-tender-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
        'render element' => 'form',
		),

		'profile_state_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-profile-state-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'profile_district_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-profile-district-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'profile_form_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-profile-form-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'mlaprofile_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-mlaprofile-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'mpsprofile_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-mpsprofile-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'rajyasabha_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-rajyasabha-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'portfolio_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-portfolio-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'map_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-map-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'whatsnew_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-whatsnew-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'school_fees_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-school-fees-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
		'static_node_form' => array(    
	        'arguments' => array('form' => NULL),
	        'template' => 'node-static-edit',
		'path' => drupal_get_path('theme','nic').'/templates',
	        'render element' => 'form',
		),
	); 
}

/*function nic_date_combo($vars) {
//print '<pre>';print_r($vars);print '</pre>';
 $element = $vars['element'];
  return '<div class="date-combo-wrapper">'. $element['#children'] .'</div>';
}*/

/**
 * Rename the Dropdown "-None-" value to "Select"
 * @param unknown_type $variables
 * @return Ambigous <The, A, Optional>
 */
function nic_options_none($variables) {
	return t('- Select -');
}